//*The wind blows in Nanjing Hangkonghangtian University,filling you with DETERMINATION
#include <bits/stdc++.h>
//use long long if necessary!
//use long long if necessary!
//use long long if necessary!
#define ll long long
#define pii pair<int,int>
using namespace std;
void read(int &n){
    int x=0,f=1;char ch=getchar();
    while (!(ch>='0'&&ch<='9')){if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    n=x*f;
}
const int N=105;
int T;
int n,m,l,vmax;
int d[N],v[N],a[N];
int p[N];
int lft[N],rit[N];
bool t[N];
int tot;
int usetot;
set<int> s[N],u;
bool usd[N];
inline int findbigger(double x){
    int ltmp=0,rtmp=m-1,res=-1;
    while (ltmp<=rtmp){
        int midtmp=(ltmp+rtmp)>>1;
        if (p[midtmp]>x){
            res=midtmp;
            rtmp=midtmp-1;
        }
        else{
            ltmp=midtmp+1;
        }
    }
    return res;
}
inline int findnotsmaller(double x){
    int ltmp=0,rtmp=m-1,res=-1;
    while (ltmp<=rtmp){
        int midtmp=(ltmp+rtmp)>>1;
        if (p[midtmp]>=x){
            res=midtmp;
            rtmp=midtmp-1;
        }
        else{
            ltmp=midtmp+1;
        }
    }
    return res;
}

inline int findsmaller(double x){
    int ltmp=0,rtmp=m-1,res=-1;
    while (ltmp<=rtmp){
        int midtmp=(ltmp+rtmp)>>1;
        if (p[midtmp]<x){
            res=midtmp;
            ltmp=midtmp+1;
        }
        else{
            rtmp=midtmp-1;
        }
    }
    return res;
}
//mark this one
inline void mrk(int x){
    t[x]=true;tot++;
}
//faster than x=max(x,y)
inline void enmax(int &x,int y){
    if (x<y){
        x=y;
    }
}
//remember to clear!
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while (T--){
        read(n);read(m);read(l);read(vmax);
        for (int i=0;i<n;i++){
            read(d[i]);read(v[i]);read(a[i]);
        }
        for (int i=0;i<m;i++){
            read(p[i]);
            //p is sorted
        }
        usetot=0;
        tot=0;
        memset(t,0,sizeof(t));
        memset(usd,0,sizeof(usd));
        u.clear();
        //ensure if t[i] is true,lft[i] and rit[i] should be changed!!!
        //because I do not memset lft[i] and rit[i] to make the program faster
        for (int i=0;i<n;i++){
            if (v[i]<=vmax){
                if (a[i]<=0){
                    //safe
                    continue;
                }
                else{
                    //a[i]>0
                    double x=(vmax*vmax-v[i]*v[i])/2.0/a[i];
                    lft[i]=findbigger(d[i]+x);
                    if (lft[i]==-1){
                        //no camera to detect
                        continue;
                    }
                    else{
                        rit[i]=m-1;
                        mrk(i);
                    }
                }
            }
            else{
                //v[i]>vmax
                lft[i]=findnotsmaller(d[i]);
                if (lft[i]==-1){
                    //no camera to detect
                    continue;
                }
                if (a[i]>=0){
                    rit[i]=m-1;
                    mrk(i);
                }
                else{
                    //a[i]<0
                    double x=(v[i]*v[i]-vmax*vmax)/2.0/abs(a[i]);
                    rit[i]=findsmaller(d[i]+x);
                    if (rit[i]!=-1&&lft[i]<=rit[i]){
                        mrk(i);
                    }
                }
            }
        }
        if (tot==0){
            puts("0 0");
            continue;
        }
        int tmpi=0;
        for (int i=0;i<m;i++){
            s[i].clear();
        }
        for (int i=0;i<n;i++){
            if (t[i]){
                for (int j=lft[i];j<=rit[i];j++){
                    s[j].insert(tmpi);
                }
                u.insert(tmpi);
                tmpi++;
            }
        }
        int maxn,maxi;
        while (!u.empty()){
            maxn=0;maxi=-1;
            for (int i=0;i<m;i++){
                if (!usd[i]){
                    if (maxn<s[i].size()){
                        maxn=s[i].size();
                        maxi=i;
                    }
                }
            }
            usd[maxi]=true;
            //use maxi
            for (int i=0;i<tot;i++){
                if (!usd[i]){
                    for (auto j=s[maxi].begin();j!=s[maxi].end();j++){
                        if (s[i].count(*j)){
                            s[i].erase(*j);
                        }
                    }
                }
            }
            for (auto j=s[maxi].begin();j!=s[maxi].end();j++){
                if (u.count(*j)){
                    u.erase(*j);
                }
            }
            usetot++;
        }
        printf("%d %d\n",tot,m-usetot);
    }//do not write anything after this!
    //do not write anything here!
    return 0;
}
//use %lld if use long long!